package org.ariadne_eu.hcifetcher.mumeUtils;

import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import org.ariadne_eu.hcifetcher.rest.RestUtils;

@Path("entries/course")
public class Course {
	
	@Path("/")
	@GET
	@Produces("application/json")
	public String getCoursesByName(@QueryParam("courseid") String id,  @QueryParam("name") String name, @QueryParam("offset") String offset, @QueryParam("size") String size) {
		int intoffset = 0, intsize = 1000;
		try{
			intoffset = Integer.parseInt(offset);
			intsize = Integer.parseInt(size);
		}catch (Exception e) {//can't parse, use default values
		}
		
		if(id != null)
			return RestUtils.getInstance().getEntityById(id).toString();
		
		Map<String, Object> filter = new HashMap<String, Object>();
		filter.put("name", name);
		return RestUtils.getInstance().JSONToString(RestUtils.getInstance().getEntriesJSON("Course", "name", name, null, intoffset, intsize, "name", true));
	}

}
